#pragma strict

private var pickObj: Transform = null;
private var hit: RaycastHit;

public var leftHand: Transform;
public var rightHand: Transform;

public var tester : GameObject;

public var mycam : Camera;

function Update()
{
	var attachScript : attachto;
	
	if(Input.GetButton("Left Hand"))
	{
		if(Physics.Raycast(mycam.main.transform.position, mycam.main.transform.parent.forward, hit, 1))
		{
		//	Instantiate(tester, hit.point, Quaternion.identity);
			if(hit.transform.tag != "Holdable") return;
			pickObj = hit.transform;	//now there's an object picked
			attachScript = pickObj.GetComponent(attachto);
			attachScript.attachTo(leftHand, gameObject);
		}
	}
	if(Input.GetButton("Right Hand"))
	{
		if(Physics.Raycast(mycam.main.transform.position, mycam.main.transform.parent.forward, hit, 1))
		{
		//	Instantiate(tester, hit.point, Quaternion.identity);
			if(hit.transform.tag != "Holdable") return;
			pickObj = hit.transform;	//now there's an object picked
			attachScript = pickObj.GetComponent(attachto);
			attachScript.attachTo(rightHand, gameObject);
		}
	}
}